//
//  Utils.swift
//  chenChat
//
//  Created by chen on 16/2/20.
//  Copyright © 2016年 chen. All rights reserved.
//

import Foundation
import UIKit

extension UIImage{
    //拉伸图片的方法
    class func resizableImage(name: String) -> UIImage {
        let image = UIImage(named: name)!
        
        let top: CGFloat = image.size.height * 0.6
        let bottom: CGFloat = image.size.height * 0.5
        let lAndr: CGFloat = image.size.height * 0.5
        
        return image.resizableImageWithCapInsets(UIEdgeInsets(top: top, left: lAndr, bottom: bottom, right: lAndr))
    }
}

extension UILabel{
    //主要是获取输入信息的高度
    class func sizeOfString(string: NSString,font: UIFont,maxWidth:CGFloat) ->CGSize {
        //boundingRectWithSize()方法
        //需要自己去了解，了解
        let size: CGSize = string.boundingRectWithSize(CGSize(width: maxWidth, height: 999), options: .UsesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil).size
        return CGSize(width: size.width + 15, height: size.height + 20)
    }
}
